<%
# View which displays a single update's information.  
#
# Author::      Eli Fox-Epstein, efoxepstein@wesleyan.edu
# Author::      Dimitar Gochev, dimitar.gochev@trincoll.edu
# Copyright::   Humanitarian FOSS Project (http://www.hfoss.org), Copyright (C) 2009.
# License::     http://www.gnu.org/copyleft/lesser.html GNU Lesser General Public License (LGPL)
%>

<% content_for :title, title(@update.title, 'Update', @incident.name, 'Incidents', @instance.short_name)%>

<% content_for :body do %>
	<%= pretty_button_if(@update.destroyable_by?(@current_user), :delete_update, instance_incident_update_path(@instance, @incident, @update), 'Delete Update', :method => :delete, :confirm => "Really delete update?") %>
	<%= pretty_button_if(@update.updatable_by?(@current_user), :edit_update, edit_instance_incident_update_path(@instance, @incident, @update), 'Edit Update') %>
	<%= flashes %>
	<div id="wrap">
		<h1>
			<%= @update.title%>
			<span class="tiny">
				&laquo; <%= link_to @incident.name, instance_incident_path(@instance,@incident) %>
			</span>
			<span class="under">
				(by <%=link_to_issuer @update%>
				on <%= time_mdy @update.created_at%>)
			</span>
		</h1>
		<p><%=simple_format(h(@update.text)) %></p>
		
		<!-- Files-->
		<% unless @update.files.empty? %>
			<div class="files">
				<em>Attached Files:</em>
				<ul class="flat-list">
				<% @update.attachments.each do |f| %>
					<li><%=link_to f.attach.original_filename, f.attach.url%></li>
				<% end %>
				</ul>
			</div>
		<% end %>
		
		<% unless @update.tags.empty? %>
			<div class="relevant-groups">
				<em>Relevant groups:</em>
				<ul class="flat-list">
				<% @update.relevant_groups.each do |g| %>
					<li><%=easy_link_to(g.name, g)%></li>
				<% end %>
				</ul>
			</div>
		<% end %>
				
		<!-- Tags -->
		<% unless @update.tags.empty? %>
			<div class="tags">
				<em>Tags:</em>
				<ul class="flat-list">
				<% @update.tags.each do |t| %>
					<li><%=easy_link_to(t.name, t)%></li>
				<% end %>
				</ul>
			</div>
		<% end %>
		<% if @update.creatable_by?(@current_user) && flash[:notice] == UPDATE_CREATED %>
        <%= link_to 'Add another update', new_instance_incident_update_path(@instance, @incident)%>
        <% end %>
	</div>
<% end %>
